const uniID = require("uni-id");
module.exports = () => {
  return async function auth(ctx, next) {
		const token=ctx.event.headers['x-token'];
		const auth = await uniID.checkToken(token);
		if (auth.code!=0) {
			throw { code: auth.code, message: auth.message };
		}
		ctx.uid = auth.uid; 
    await next();
  };
};